package com.hsx.service.user;

import com.hsx.dao.BaseDao;
import com.hsx.dao.user.UserDao;
import com.hsx.dao.user.UserDaoImpl;
import com.hsx.pojo.User;
import org.junit.Test;

import java.sql.Connection;
import java.sql.SQLException;

public class UserServiceImpl implements UserService{
    private UserDao userDao;
    public UserServiceImpl(){
         userDao=new UserDaoImpl();
    }

    public User login(String userCode, String userPassword){
        Connection connection=null;
        //  System.out.println("1");
        User user=null;
        //   System.out.println("2");
        connection=BaseDao.getConnection();
        // System.out.println("3");
        try {
            //  System.out.println("4");
            user= userDao.getLoginUser(connection, userCode);
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            //   System.out.println("5");
            BaseDao.closeResource(connection,null,null);
            //  System.out.println("6");
        }
        // System.out.println("7");
        return  user;
    }
    @Test
    public void Test(){
        UserServiceImpl userService = new UserServiceImpl();
        User hsx = userService.login("admin", "1234567");
        System.out.println(hsx.getUserCode());
        System.out.println(hsx.getUserPassword());
        }
        }
